<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="jquery-3.1.1.js"></script>
</head>
<body>

<button>全选</button>
<button>反选</button>
<button>取消</button>


<hr>
<table border="1">
    <tr>
        <th>     </th>
        <th>姓名</th>
        <th>年龄</th>
        <th>班级</th>
    </tr>

    <tr>
        <td><input type="checkbox"></td>
        <td>111</td>
        <td>111</td>
        <td>111</td>
    </tr>

     <tr>
        <td><input type="checkbox"></td>
        <td>111</td>
        <td>111</td>
        <td>111</td>
    </tr>

     <tr>
        <td><input type="checkbox"></td>
        <td>111</td>
        <td>111</td>
        <td>111</td>
    </tr>

</table>
<script type="text/javascript">
    $("button").click(function() {
        if ($(this).text() == '全选') {
            $("input").prop("checked", true);
        } 
        else if ($(this).text() == '取消') {
            $("input").prop('checked', false);
        } 
        else {
            $("input").each(function() {
                $(this).prop('checked', !$(this).prop('checked'))
            });
        };
    });
</script>

</body>
</html>